class Config {
    constructor() {
        this.phone = this.getItem('phone') || '';
        this.documenttest = false;
        // token过期时间
        this.ExpirationDate = 300
        this.title = '河口'
        this.authObject = this.getItem('authObject');
        this.mode = "produce";
        if (this.mode === "dev") {
            // 服务器ip端口
            this.interport = {
                ip: 'wx.gisocn.com',
                port: 18099,
                host: 'http://wx.gisocn.com:18099/'
            }
        } else {
            // 服务器ip端口
            this.interport = {
                ip: 'www.hkqwgb.cn',
                port: 8080,
                host: 'http://www.hkqwgb.cn:8080/',
            }
        }
        // 用户名密码
        this.login = this.getItem('login') || {
            userName: '',
            password: ''
        }
        // 当前地址信息
        this.address = this.getItem('location') || {
            address: "",
            location: "",
            name: "",
        }
        this.wxaddress = {

        }
        this.location = this.getItem('location') || {
            address: "",
            latitude: "",
            longitude: "",
        };
    }
    // 存储数据
    setItem(name, value) {
        if (typeof (value) == 'object' || typeof (value) == 'array') {
            value = JSON.stringify(value)
        }
        window.localStorage.setItem(name, value)
    }
    // 读取数据
    getItem(name) {
        var data = ''
        data = window.localStorage.getItem(name)
        try {
            let r = JSON.parse(data)
            return r
        } catch {
            return data
        }
    }
    setTitle(name) {
        this.setItem('title', name)
        this['title'] = name
        document.title = name
    }
    // 存储数据
    setApiData(name, data) {
        this.setItem(name, data)
        this[name] = data
    }
}

export default Config;